package org.comeday.idempotent.controller;

import jakarta.annotation.Resource;
import org.comeday.idempotent.service.IdempotentStorage;
import org.comeday.idempotent.util.IdGeneratorUtil;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Program Name: spring_study
 * <p>
 * Description:
 * <p>
 * Created by hkrong on 2024/11/24 17:35
 *
 * @author hkrong
 * @version 1.0
 */
@RestController
@RequestMapping("idGenerator")
public class IdGeneratorController {

    @Resource
    private IdempotentStorage idempotentStorage;

    @RequestMapping("getIdToken")
    public String getIdGeneratorToken() {
        String generateId = IdGeneratorUtil.generateId();
        idempotentStorage.save(generateId);
        return generateId;
    }
}
